# -*- coding: utf-8 -*-
"""
-------------------------------------------------
Project Name: luffcity study project
File Name: 信号量练习和理解.py
Author: kij
Create Date: 2021/3/19
-------------------------------------------------
"""
from threading import Thread, Semaphore, currentThread
import time, random

sm = Semaphore(3)


def task():
	with sm:
		print('%s in ' % currentThread().getName())
		time.sleep(random.randint(1, 3))


if __name__ == '__main__':
	for i in range(10):
		t = Thread(target=task)
		t.start()
